//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.qst.crop.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qst.crop.dao.ExpertDao;
import com.qst.crop.entity.Expert;
import com.qst.crop.service.ExpertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ExpertServiceImpl implements ExpertService {
    @Autowired
    private ExpertDao expertDao;
    private Integer pageSize = 30;

    public ExpertServiceImpl() {
    }

    public Expert selectById(String name) {
        Expert expert = this.expertDao.selectByPrimaryKey(name);
        return expert;
    }

    public List<Expert> selectAllExpert() {
        List<Expert> experts = this.expertDao.selectAllExpert();
        return experts;
    }

    public void delete(String name) {
        this.expertDao.deleteByPrimaryKey(name);
    }

    public void insert(Expert expert) {
        this.expertDao.insertSelective(expert);
    }

    public void updateById(Expert expert) {
        this.expertDao.updateByPrimaryKeySelective(expert);
    }

    public PageInfo<Expert> findPage(Integer pageNum) {
        PageHelper.startPage(pageNum, this.pageSize);
        List<Expert> experts = this.expertDao.selectAllExpert();
        PageInfo<Expert> expertPageInfo = new PageInfo(experts);
        return expertPageInfo;
    }

    public PageInfo<Expert> findPageByKeys(String keys, Integer pageNum) {
        PageHelper.startPage(pageNum, this.pageSize);
        List<Expert> experts = this.expertDao.selectAllByKeys(keys);
        PageInfo<Expert> orderPageInfo = new PageInfo(experts);
        return orderPageInfo;
    }
}
